local sk__yinzi = fk.CreateSkill {

  name = "sk__yinzi",

  tags = { Skill.Compulsory, },

}



sk__yinzi:addEffect(fk.AfterCardsMove, {
  name = "sk__yinzi",
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(sk__yinzi.name) then return end
    local turn_event = player.room.logic:getCurrentEvent():findParent(GameEvent.Turn)
    if turn_event == nil then return end
    if player:isWounded() then
      for _, move in ipairs(data) do
        if move.to and move.to ~= player and move.toArea == Card.PlayerHand and
            move.to.phase == Player.NotActive and
            not table.contains(player:getTableMark("sk__yinzi1-turn"), move.to.id) then
          event:setCostData(self, move.to.id)
          return true
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:addTableMark(player, "sk__yinzi1-turn", event:getCostData(self))
    room:recover {
      who = player,
      num = 1,
      recoverBy = player,
      skillName = sk__yinzi.name,
    }
  end,
})
sk__yinzi:addEffect(fk.HpRecover, {
  name = "sk__yinzi",
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(sk__yinzi.name) then return end
    local turn_event = player.room.logic:getCurrentEvent():findParent(GameEvent.Turn)
    if turn_event == nil then return end
    if target ~= player then
      return target.phase == Player.NotActive and not table.contains(player:getTableMark("sk__yinzi2-turn"), target.id)
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:addTableMark(player, "sk__yinzi2-turn", target.id)
    player:drawCards(2, sk__yinzi.name)
  end,
})

return sk__yinzi
